<script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator'
import { CreateElement } from 'vue'

@Component({
  name: 'RenderTimePicker'
})
export default class extends Vue {
  @Prop()
  private value!: string | number | Date | Array<string | number | Date> | null
  // whether to use fixed time picker
  @Prop({ type: Boolean, required: false, default: false })
  private isSelect!: boolean

  render (h: CreateElement) {
    let component = this.isSelect ? 'el-time-select' : 'el-time-picker'
    return h(component, {
      attrs: this.$attrs,
      props: { ...this.$attrs, value: this.value },
      on: {
        ...this.$listeners,
        input: (
          v: string | number | Date | Array<string | number | Date> | null
        ) => {
          this.$emit('input', v)
        }
      }
    })
  }
}
</script>
